/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package comunications;

import crashManager.CrashManager;
import gameState.Player;
import gameState.Ring;
import gameState.Table;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author DEX
 */

public class SendRing extends Thread{

        private Player player;
        private Ring ring;
        Logger logger = Logger.getLogger(this.getClass().getSimpleName());


        public SendRing(Ring r, Player p) {
                this.player=p;
                this.ring=r;
        }


        public void run() {

                try{
                        Registry registry = LocateRegistry.getRegistry(player.getIp(), player.getPort());
                        ClientComunicateInterface cci = (ClientComunicateInterface)registry.lookup("ClientComunicateImpl");
                        cci.bringRing(ring);
                        logger.log(Level.INFO, "[SendRing] ring inviato a "+player.getIp());
                }
                catch(Exception e){
                    e.printStackTrace();
                    CrashManager cm = new CrashManager();
                    cm.solveNext();
                    this.run();
                }
        }
}

